"""Default router for Dingo.

Copyright (C) Sarah Mount 2008.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
"""

from __future__ import absolute_import
del absolute_import
from .. import RoutingModel


class OneHopP2P(RoutingModel.RoutingModel):
    """Default router.
    """
    def __init__(self, maxHopCount=10):
        RoutingModel.RoutingModel.__init__(self)
        self.name = 'One-hop peer to peer'
        return
    def send(self, arc_colour):
        if not self.send_q.empty():
            msg = self.send_q.get()
            msg.time_sent = self.clock() # will one day be the time model.
            if msg.receiver_id: self.radio.send(msg, arc_colour)
            else: 
		self.radio.broadcast(msg, arc_colour)
            return
        return
    def recv(self):
        if not self.recv_q.empty():
            return self.recv_q.get()


defaultRouter = OneHopP2P()
